#!/usr/bin/env escript

main([A]) ->
	process(list_to_integer(A)).
	
wait() ->
	receive
		_ -> void
	end.
			
process(N) ->
	statistics(runtime),
	statistics(wall_clock),
	Pids = lists:map(fun(_) -> spawn(fun() -> wait() end) end, lists:seq(1, N)),
	{_, Runtime} = statistics(runtime),
	{_, WallClock} = statistics(wall_clock),
	lists:map(fun(Pid) -> Pid ! done end, Pids),
	io:format("microseconds: Runtime ~p WallClock ~p~n", [Runtime * 1000/N, WallClock * 1000/N]).
	
% Run this with some examples as follows
% process_timing 5000
% process_timing 10000
% process_timing 15000
% process_timing 20000
